package edu.tjpu.share.util;

import java.util.Iterator;
import java.util.List;

import edu.tjpu.share.po.Classes;
import edu.tjpu.share.po.FileForDownload;
import edu.tjpu.share.po.Grade;
import edu.tjpu.share.po.Major;
import edu.tjpu.share.po.UserVo;

public class ListUtil {
	public static int[] getGradeIDRelation(List<Grade> list) {
		int[] relation = new int[list.size()];
		Iterator<Grade> listIterator = list.iterator();
		int i = 0;
		while (listIterator.hasNext()) {
			Grade grade = listIterator.next();
			relation[i] = grade.getGid();
			i++;
		}
		return relation;

	}

	public static int[] getMajorIDRelation(List<Major> list) {
		int[] relation = new int[list.size()];
		Iterator<Major> listIterator = list.iterator();
		int i = 0;
		while (listIterator.hasNext()) {
			Major major = listIterator.next();
			relation[i] = major.getMid();
			i++;
		}
		return relation;

	}

	public static int[] getClassIDRelation(List<Classes> list) {
		int[] relation = new int[list.size()];
		Iterator<Classes> listIterator = list.iterator();
		int i = 0;
		while (listIterator.hasNext()) {
			Classes classes = listIterator.next();
			relation[i] = classes.getCid();
			i++;
		}
		return relation;

	}

	public static int[] getUserIDRelation(List<UserVo> list) {
		int[] relation = new int[list.size()];
		Iterator<UserVo> listIterator = list.iterator();
		int i = 0;
		while (listIterator.hasNext()) {
			UserVo user = listIterator.next();
			relation[i] = user.getUid();
			i++;
		}
		return relation;
	}
	
	public static int[] getFileIDRelation(List<FileForDownload> list) {
		int[] relation = new int[list.size()];
		Iterator<FileForDownload> listIterator = list.iterator();
		int i = 0;
		while (listIterator.hasNext()) {
			FileForDownload file = listIterator.next();
			relation[i] = file.getFid();
			i++;
		}
		return relation;
	}
}
